package com.ruoyi.system.service.impl;

import java.util.List;

import com.ruoyi.system.domain.Emplyee;
import com.ruoyi.system.mapper.EmplyeeMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.WorkOverMapper;
import com.ruoyi.system.domain.WorkOver;
import com.ruoyi.system.service.IWorkOverService;

/**
 * 加班申请表Service业务层处理
 *
 * @author ruoyi
 * @date 2023-10-17
 */
@Service
public class WorkOverServiceImpl implements IWorkOverService
{
    @Autowired
    private WorkOverMapper workOverMapper;

    @Autowired
    private EmplyeeMapper emplyeeMapper;

    /**
     * 查询加班申请表
     *
     * @param id 加班申请表主键
     * @return 加班申请表
     */
    @Override
    public WorkOver selectWorkOverById(Long id)
    {
        return workOverMapper.selectWorkOverById(id);
    }

    /**
     * 查询加班申请表列表
     *
     * @param workOver 加班申请表
     * @return 加班申请表
     */
    @Override
    public List<WorkOver> selectWorkOverList(WorkOver workOver)
    {
        List<WorkOver> workOvers = workOverMapper.selectWorkOverList(workOver);
        for (WorkOver over : workOvers) {
            Emplyee emplyee = emplyeeMapper.selectEmplyeeByEno(over.getEno());
            if(emplyee!=null){
                over.setName(emplyee.getName());
            }
        }
        return workOvers;
    }

    /**
     * 新增加班申请表
     *
     * @param workOver 加班申请表
     * @return 结果
     */
    @Override
    public int insertWorkOver(WorkOver workOver)
    {
        return workOverMapper.insertWorkOver(workOver);
    }

    /**
     * 修改加班申请表
     *
     * @param workOver 加班申请表
     * @return 结果
     */
    @Override
    public int updateWorkOver(WorkOver workOver)
    {
        return workOverMapper.updateWorkOver(workOver);
    }

    /**
     * 批量删除加班申请表
     *
     * @param ids 需要删除的加班申请表主键
     * @return 结果
     */
    @Override
    public int deleteWorkOverByIds(Long[] ids)
    {
        return workOverMapper.deleteWorkOverByIds(ids);
    }

    /**
     * 删除加班申请表信息
     *
     * @param id 加班申请表主键
     * @return 结果
     */
    @Override
    public int deleteWorkOverById(Long id)
    {
        return workOverMapper.deleteWorkOverById(id);
    }
}
